package java_thinking.unit_21._21_10;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Desc:
 * @author: cww
 * @DateTime: 2019/6/20 18:56
 */

public class Account {
    private DollarAmount balance;
    private final int acctNo;
    private static final AtomicInteger sequence = new AtomicInteger();

    public Account() {
        acctNo = sequence.incrementAndGet();
    }

    void debit(DollarAmount d) {
        balance = balance.subtract(d);
    }

    void credit(DollarAmount d) {
        balance = balance.add(d);
    }

    DollarAmount getBalance() {
        return balance;
    }

    int getAcctNo() {
        return acctNo;
    }
}
